<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<sec:authentication property="principal" var="currentPrincipal" scope="page" />

<fmt:setBundle basename="ApplicationMessage" />
<fmt:setLocale value="zh_CN" />

<!DOCTYPE html>
<html lang="zh-CN">
<head>

<%@ include file="/WEB-INF/include/meta.jsp"%>
<%@ include file="/WEB-INF/include/css.jsp"%>

</head>

<body class="ms-theme-blue">

  <%@ include file="/WEB-INF/include/header.jsp"%>
  <%@ include file="/WEB-INF/include/submenu.jsp"%>

  <div class="container-fluid ms-container has-ms-sidemenu">

    <ol class="ms-breadcrumb breadcrumb">
      <li class="active">代理管理&nbsp;&nbsp;-&nbsp;&nbsp;二级代理详情</li>
    </ol>

    <div class="ms-content-layout ">
      <div class="form-horizontal ms-form form-personal-info">
        <div class="form-group ms-form-group">
          <label class="control-label col-xs-2" style="width: 12%;">代理名称：</label>
          <div class="col-xs-2">
            <p class="form-control-static">${agentCompany.name}</p>
          </div>
          
          <label class="control-label col-xs-2" style="width: 12%;">代理类型：</label>
          <div class="col-xs-2">
            <p class="form-control-static">${agentCompany.type.description}</p>
          </div>
        </div>
        
        <div class="form-group ms-form-group">
          <label class="control-label col-xs-2" style="width: 12%;">公司名称：</label>
          <div class="col-xs-2">
          <c:choose>
          <c:when test="${agentCompany.companyName == ''}">
          <p class="form-control-static">-</p>
          </c:when>
          <c:otherwise>
          <p class="form-control-static">${agentCompany.companyName}</p>
          </c:otherwise>
        </c:choose>
            
          </div>
          
          <label class="control-label col-xs-2" style="width: 12%;">公司地址：</label>
          <div class="col-xs-2">
            <p class="form-control-static">${agentCompany.companyAddress}</p>
          </div>
        </div>
        
        <div class="form-group ms-form-group">
          <label class="control-label col-xs-2" style="width: 12%;">所属销售：</label>
          <div class="col-xs-2">
            <p class="form-control-static">${agentCompany.principal.name}</p>
          </div>
          
          <label class="control-label col-xs-2" style="width: 12%;">所属分区：</label>
          <div class="col-xs-2">
            <p class="form-control-static">${agentCompany.district.name}</p>
          </div>
        </div>
        
        <div class="form-group ms-form-group">
          <label class="control-label col-xs-2" style="width: 12%;">返点率：</label>
          <div class="col-xs-2">
            <p class="form-control-static"><fmt:formatNumber type="percent" maxFractionDigits="4"  pattern="0.00%" value="${agentCompany.rate/100}" /></p>
          </div>
          
          <label class="control-label col-xs-2" style="width: 12%;">是否冻结：</label>
          <div class="col-xs-2">
            <c:if test="${agentCompany.disabled==false}">
              <p class="form-control-static">否</p>
            </c:if>
            <c:if test="${agentCompany.disabled==true}">
              <p class="form-control-static">是</p>
            </c:if>
          </div>
        </div>
        
        <div class="form-group ms-form-group">
          <label class="control-label col-xs-2" style="width: 12%;">联系人手机：</label>
          <div class="col-xs-2">
            <p class="form-control-static">${agentCompany.conactMobile}</p>
          </div>
          
          <label class="control-label col-xs-2" style="width: 12%;">联系人Email：</label>
          <div class="col-xs-2">
            <p class="form-control-static">${agentCompany.contactEmail}</p>
          </div>
        </div>
        
        <div class="form-group ms-form-group">
          
          
          <label class="control-label col-xs-2" style="width: 12%;">创建时间：</label>
          <div class="col-xs-2">
            <p class="form-control-static">${agentCompany.createTime}</p>
          </div>
        </div>

      <c:choose>
        <c:when test="${agentCompany.team}">
        <div class="row">
          <div class="block-heading">
            <h5>代理人列表</h5>
          </div>

          <table class="table table-hover ms-table">
            <thead>
              <tr>
                <th>序号</th>
                <th>姓名</th>
                <th>email</th>
                <th>手机</th>
                <th>是否冻结</th>
                <th>操作</th>
              </tr>
            </thead>
            <tbody>
              <c:forEach var="agent" items="${agents}" varStatus="status">
                <tr>
                  <td>${status.index+1}</td>
                  <td>${agent.name}</td>
                  <td>${agent.email }</td>
                  <td>${agent.mobile }</td>
                  <c:if test="${agent.disabled==false}">
                  <td>否</td>
                  </c:if>
                  <c:if test="${agent.disabled==true}">
                  <td>是</td>
                  </c:if>
                  <td class="text-center">
                    <a href="${ctx.host}/agents/${agentCompany.id}/agents/${agent.id} " data-target="#edit" data-toggle="modal">编辑</a>&nbsp;&nbsp;
                    <c:if test="${agent.disabled==false}">
                        <a href="${ctx.host}/agents/${agent.id}/freeze-agent" data-target="#freeze" data-toggle="modal">冻结</a>
                    </c:if> 
                    <c:if test="${agent.disabled==true}">
                        <a href="${ctx.host}/agents/${agent.id}/activate-agent" data-target="#activate" data-toggle="modal">激活</a>
                    </c:if> 
                  </td>
                </tr>
              </c:forEach>
            </tbody>
          </table>
        </div>
        </c:when>
        <c:otherwise>
        <div class="row">
          <div class="block-heading">
            <h5>代理人</h5>
          </div>

          <table class="table table-hover ms-table">
            <thead>
              <tr>
                <th>序号</th>
                <th>姓名</th>
                <th>email</th>
                <th>手机</th>
                <th>是否冻结</th>
                <th>操作</th>
              </tr>
            </thead>
            <tbody>
              <c:forEach var="agent" items="${agents}" varStatus="status">
                <tr>
                  <td>${status.index+1}</td>
                  <td>${agent.name}</td>
                  <td>${agent.email }</td>
                  <td>${agent.mobile }</td>
                  <c:if test="${agent.disabled==false}">
                  <td>否</td>
                  </c:if>
                  <c:if test="${agent.disabled==true}">
                  <td>是</td>
                  </c:if>
                  <td class="text-center">
                    <a href="${ctx.host}/agents/${agentCompany.id}/agents/${agent.id} " data-target="#edit" data-toggle="modal">编辑</a>&nbsp;&nbsp;
                    <c:if test="${agent.disabled==false}">
                        <a href="${ctx.host}/agents/${agent.id}/freeze-agent" data-target="#freeze" data-toggle="modal">冻结</a>
                    </c:if> 
                    <c:if test="${agent.disabled==true}">
                        <a href="${ctx.host}/agents/${agent.id}/activate-agent" data-target="#activate" data-toggle="modal">激活</a>
                    </c:if> 
                  </td>
                </tr>
              </c:forEach>
            </tbody>
          </table>
        </div>
        </c:otherwise>
        </c:choose>
      </div>


    </div>
  </div>
  <%@ include file="/WEB-INF/include/script.jsp"%>
   <d:resource root="${ctx.resource}/build" type="script" src="js/page/agent/agent-view.js" />
 <script type="text/javascript">
        require([ 'page/agent/agent-view' ], function(page) {
            page.init();
        })
    </script>
</body>
</html>